package com.xdq.controller;

import com.xdq.bean.User;
import com.xdq.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * @author: 徐东强
 * @date: 2018/9/27 上午11:49
 * @description:
 **/
@RestController
@RequestMapping("/api/user")
public class UserController {

    private final UserService userService;

    @Autowired
    public UserController(UserService userService) {
        this.userService = userService;
    }

    @GetMapping("/one")
    public User getOneUser(String username){
        return this.userService.findUserByName(username)
                .orElse(null);
    }

    @PostMapping()
    public User getUser(@RequestParam String token, @RequestBody User user, @RequestHeader Map<String, Object> headers){
//        String nul = null;
//        nul.length();
        System.out.println("======" + token);
        return new User("id", "xdq", "123456");
    }
}
